using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace SdmxMl.UC
{
	/// <summary>
	/// Summary description for DualListForm.
	/// </summary>
	public class DualListForm : System.Windows.Forms.Form
	{
		///////////////////////////////////////////////////////////////////////
		#region Designer generated Members

		private System.Windows.Forms.ListBox listAvailable;
		private System.Windows.Forms.ListBox listAssigned;
		private System.Windows.Forms.Button buttonAdd;
		private System.Windows.Forms.Button buttonDelete;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.Label label2;
		private SdmxMl.UC.DualList dualListAdd;
		private SdmxMl.UC.DualList dualListDelete;
		private System.Windows.Forms.Button butOK;
		private System.Windows.Forms.Panel panelLeft;
		private System.Windows.Forms.Panel panelMiddle;
		private System.Windows.Forms.Panel panelRight;
		private System.ComponentModel.IContainer components;

		#endregion

		/// <summary> List container to holds available items </summary>
		public ListBox ListAvailable
		{
			get { return this.listAvailable; }
		}

		/// <summary> List container to holds selected items </summary>
		public ListBox ListAssigned
		{
			get {	return this.listAssigned;		}
		}

		///////////////////////////////////////////////////////////////////////
		#region Construction
		/// <summary>
		/// C'tor
		/// </summary>
		public DualListForm()
		{
			// Required for Windows Form Designer support
			InitializeComponent();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
		#endregion

		///////////////////////////////////////////////////////////////////////
		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
            this.components = new System.ComponentModel.Container();
            this.listAvailable = new System.Windows.Forms.ListBox();
            this.listAssigned = new System.Windows.Forms.ListBox();
            this.dualListAdd = new SdmxMl.UC.DualList(this.components);
            this.buttonAdd = new System.Windows.Forms.Button();
            this.dualListDelete = new SdmxMl.UC.DualList(this.components);
            this.buttonDelete = new System.Windows.Forms.Button();
            this.label1 = new System.Windows.Forms.Label();
            this.label2 = new System.Windows.Forms.Label();
            this.butOK = new System.Windows.Forms.Button();
            this.panelLeft = new System.Windows.Forms.Panel();
            this.panelMiddle = new System.Windows.Forms.Panel();
            this.panelRight = new System.Windows.Forms.Panel();
            this.panelLeft.SuspendLayout();
            this.panelMiddle.SuspendLayout();
            this.panelRight.SuspendLayout();
            this.SuspendLayout();
            // 
            // listAvailable
            // 
            this.listAvailable.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.listAvailable.Location = new System.Drawing.Point(8, 24);
            this.listAvailable.Name = "listAvailable";
            this.listAvailable.ScrollAlwaysVisible = true;
            this.listAvailable.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
            this.listAvailable.Size = new System.Drawing.Size(160, 108);
            this.listAvailable.Sorted = true;
            this.listAvailable.TabIndex = 0;
            // 
            // listAssigned
            // 
            this.listAssigned.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
                        | System.Windows.Forms.AnchorStyles.Left)
                        | System.Windows.Forms.AnchorStyles.Right)));
            this.listAssigned.Location = new System.Drawing.Point(8, 24);
            this.listAssigned.Name = "listAssigned";
            this.listAssigned.ScrollAlwaysVisible = true;
            this.listAssigned.SelectionMode = System.Windows.Forms.SelectionMode.MultiExtended;
            this.listAssigned.Size = new System.Drawing.Size(160, 108);
            this.listAssigned.TabIndex = 1;
            // 
            // dualListAdd
            // 
            this.dualListAdd.AutoDisableButton = true;
            this.dualListAdd.Button = this.buttonAdd;
            this.dualListAdd.DoubleClickSupport = true;
            this.dualListAdd.ListBoxFrom = this.listAvailable;
            this.dualListAdd.ListBoxTo = this.listAssigned;
            this.dualListAdd.BeforeAction += new SdmxMl.UC.BeforeActionHandler(this.dualListAdd_BeforeAction);
            this.dualListAdd.AfterAction += new SdmxMl.UC.AfterActionHandler(this.dualListAdd_AfterAction);
            // 
            // buttonAdd
            // 
            this.buttonAdd.Location = new System.Drawing.Point(8, 24);
            this.buttonAdd.Name = "buttonAdd";
            this.buttonAdd.Size = new System.Drawing.Size(32, 24);
            this.buttonAdd.TabIndex = 2;
            this.buttonAdd.Text = ">";
            // 
            // dualListDelete
            // 
            this.dualListDelete.AutoDisableButton = true;
            this.dualListDelete.Button = this.buttonDelete;
            this.dualListDelete.DoubleClickSupport = true;
            this.dualListDelete.ListBoxFrom = this.listAssigned;
            this.dualListDelete.ListBoxTo = this.listAvailable;
            this.dualListDelete.BeforeAction += new SdmxMl.UC.BeforeActionHandler(this.dualListDelete_BeforeAction);
            this.dualListDelete.AfterAction += new SdmxMl.UC.AfterActionHandler(this.dualListDelete_AfterAction);
            // 
            // buttonDelete
            // 
            this.buttonDelete.Location = new System.Drawing.Point(8, 64);
            this.buttonDelete.Name = "buttonDelete";
            this.buttonDelete.Size = new System.Drawing.Size(32, 24);
            this.buttonDelete.TabIndex = 3;
            this.buttonDelete.Text = "<";
            // 
            // label1
            // 
            this.label1.Location = new System.Drawing.Point(8, 8);
            this.label1.Name = "label1";
            this.label1.Size = new System.Drawing.Size(100, 16);
            this.label1.TabIndex = 4;
            this.label1.Text = "Available:";
            // 
            // label2
            // 
            this.label2.Location = new System.Drawing.Point(8, 8);
            this.label2.Name = "label2";
            this.label2.Size = new System.Drawing.Size(100, 16);
            this.label2.TabIndex = 5;
            this.label2.Text = "Assigned:";
            // 
            // butOK
            // 
            this.butOK.DialogResult = System.Windows.Forms.DialogResult.OK;
            this.butOK.Location = new System.Drawing.Point(8, 104);
            this.butOK.Name = "butOK";
            this.butOK.Size = new System.Drawing.Size(32, 24);
            this.butOK.TabIndex = 6;
            this.butOK.Text = "Ok";
            // 
            // panelLeft
            // 
            this.panelLeft.Controls.Add(this.label1);
            this.panelLeft.Controls.Add(this.listAvailable);
            this.panelLeft.Dock = System.Windows.Forms.DockStyle.Left;
            this.panelLeft.Location = new System.Drawing.Point(0, 0);
            this.panelLeft.Name = "panelLeft";
            this.panelLeft.Size = new System.Drawing.Size(176, 142);
            this.panelLeft.TabIndex = 7;
            // 
            // panelMiddle
            // 
            this.panelMiddle.Controls.Add(this.butOK);
            this.panelMiddle.Controls.Add(this.buttonAdd);
            this.panelMiddle.Controls.Add(this.buttonDelete);
            this.panelMiddle.Dock = System.Windows.Forms.DockStyle.Left;
            this.panelMiddle.Location = new System.Drawing.Point(176, 0);
            this.panelMiddle.Name = "panelMiddle";
            this.panelMiddle.Size = new System.Drawing.Size(48, 142);
            this.panelMiddle.TabIndex = 8;
            // 
            // panelRight
            // 
            this.panelRight.Controls.Add(this.listAssigned);
            this.panelRight.Controls.Add(this.label2);
            this.panelRight.Dock = System.Windows.Forms.DockStyle.Fill;
            this.panelRight.Location = new System.Drawing.Point(224, 0);
            this.panelRight.Name = "panelRight";
            this.panelRight.Size = new System.Drawing.Size(176, 142);
            this.panelRight.TabIndex = 9;
            // 
            // DualListForm
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            this.ClientSize = new System.Drawing.Size(400, 142);
            this.Controls.Add(this.panelRight);
            this.Controls.Add(this.panelMiddle);
            this.Controls.Add(this.panelLeft);
            this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
            this.Name = "DualListForm";
            this.ShowInTaskbar = false;
            this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
            this.Resize += new System.EventHandler(this.DualListForm_Resize);
            this.panelLeft.ResumeLayout(false);
            this.panelMiddle.ResumeLayout(false);
            this.panelRight.ResumeLayout(false);
            this.ResumeLayout(false);

		}
		#endregion

		/// <summary>
		/// Exposes the DualListAdd.
		/// </summary>
		public SdmxMl.UC.DualList DualListAdd
		{
			get { return dualListAdd; }
		}

		private void dualListAdd_AfterAction(object sender, DualListActionEventArgs e)
		{
			listAssigned.SelectedIndex = e.Index;
		}

		private void dualListDelete_AfterAction(object sender, DualListActionEventArgs e)
		{
			listAvailable.SelectedIndex = e.Index;
		}

		private void dualListAdd_BeforeAction(object sender, SdmxMl.UC.DualListActionCancelEventArgs e)
		{
		}

		private void DualListForm_Resize(object sender, System.EventArgs e)
		{
			int middle = this.panelMiddle.Width;
			int width = (this.Width / 2) - middle / 2;
			this.panelLeft.Width = width;
			this.panelRight.Width = width;
		}

        private void dualListDelete_BeforeAction(object sender, DualListActionCancelEventArgs e)
        {

        }
	}
}
